package ar.uba.dc.cmovil.tripplanner.services;

import android.os.AsyncTask;

import java.util.List;
import java.util.Map;

/**
 * Created by anton on 10/16/13.
 */
public class FindTweetsCountByPlaceTask extends AsyncTask<List<String>, Void, Map<String, Integer>> {

    private HttpTaskHandler<Map<String, Integer>> callback;
    private Map<String, Integer> result;

    public FindTweetsCountByPlaceTask(HttpTaskHandler<Map<String, Integer>> callback) {
        super();
        this.callback = callback;
    }

    @Override
    protected Map<String, Integer> doInBackground(List<String>... places) {
        result = TwitterService.getInstance().countTweetsByPlaces(places[0]);
        return result;
    }

    @Override
    protected void onPostExecute(Map<String, Integer> statuses) {
        super.onPostExecute(statuses);
        callback.onSuccess(result);
    }
}
